<template>
  <div class="box">
    <!-- 标题 -->
    <div class="title">
      <div class="title_fan">
        <div class="el-icon-arrow-left" @click="$router.go(-1)"></div>
        <div>{{ $t('Payment') }}</div>
        <img src="../../../../assets/static/walletDetail/6.png" alt="">
      </div>
      <!-- 文字 钱包余额 -->
      <div class="title_cen">
        <span class="userName">iJoozPay Wallet</span>
<!--        <img src="../../../../assets/static/walletDetail/4.png" alt="">-->
        <div class="title_cen_size">{{ $t('Balance') }}</div>
        <div class="title_cen_flex">
          <img src="../../../../assets/static/walletDetail/12.png" alt="">
          <div>{{ info.balance }}</div>
        </div>
      </div>
    </div>
    <!-- 背景card -->
    <div class="back_card">
      <div class="back_card_flex">
        <div @click="$router.push({path:'/listautoRcharge'})" class="back_card_ten">{{ $t('Deposit') }}</div>
        <div @click="$router.push({path:'/listaddReceiverAccount'})"
             class="back_card_eleven">{{ $t('Transfer') }}
        </div>
      </div>
      <div class="back_card_nine">
        <img src="../../../../assets/static/walletDetail/5.png" alt="">
        <div class="back_card_nine_shu"></div>
        <img src="../../../../assets/static/walletDetail/1.png" alt="">
        <div class="back_card_nine_juli">{{ $t('了解如何保障您的钱包安全') }}</div>
      </div>
      <div class="back_card_color">
        <div>
          <img src="../../../../assets/static/walletDetail/14.png" alt="">
          <div>{{ $t('Homepage') }}</div>
        </div>
        <div @click="$router.push({path:'/listmembership'})" class="back_card_color_right">
          <div>{{ $t('Set up Now') }}</div>
          <div class="el-icon-arrow-right"></div>
        </div>
      </div>
    </div>
    <!-- 最近交易 -->
    <div class="painting_img recentlyDeal">
      <div class="painting_img_title">
        <img src="../../../../assets/static/recharge/q4.png" alt=""/>
        <div>{{ $t('Recent Transactions') }}</div>
      </div>
      <!--无交易记录时-->
      <div v-show="dataList.length===0" class="height_flex">
        <div class="height_flex_img col-wrapper">
          <img src="../../../../assets/static/activities/box.png" alt="">
          <div class="height_flex_size">还没有任何交易记录！</div>
          <div>当您使用我们的服务时，会在这里看到最近的交易记录。</div>
        </div>
      </div>
      <!--      有消费记录时-->
      <div v-show="dataList.length>0" class="col-wrapper comsum" style="width:100%">
        <div v-for="(item,index) in dataList" :key="index" style="width: 100%">
          <div class="card_back"
               @click="$router.push({path:'/listConsumptionDetail',query:{id:info.id}})"
               v-for="(info,subIndex) in item.data" :key="subIndex">
            <div>
              <img src="../../../../assets/static/Consumption/q1.png" alt="">
              <div>
                <div>{{ info.remark }}</div>
                <div>{{ checkTime(info.create_time) }}</div>
              </div>
            </div>
            <div>
              <!--              <span>{{ info.type }}</span>-->
              <span>{{ Number(info.money) }}</span>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import {myInfo} from '@/api/merbership/my'
import {index} from '@/api/merbership/recharge'
import '@/styles/flax.css'

export default {
  data() {
    return {
      info: {
        balance: ''
      },
      dataList: [],
      icon: '\ue630 搜索',
      userInfo: {},
      searchContent: ''
    }
  },
  activated() {
    this.myInfo()
    this.index()
  },
  methods: {
    /**
     * 时间戳判断
     * @param timeStamp
     * @returns {string}
     */
    checkTime(timeStamp) {
      let timeStr = new Date(Number(timeStamp * 1000))
      // return timeStr.toLocaleTimeString()
      return timeStr.toLocaleString()
    },
    /**
     * 搜索框失去焦点时
     */
    searchFocusOut() {
      this.icon = '\ue630 搜索'
    },
    /**
     * 搜索框获取焦点时
     */
    searchFocus() {
      this.icon = ''
    },
    // ---------------------- axios ------------------
    /**
     * 我的消费记录
     */
    index() {
      const pd = {
        today: '1'
      }
      index(this.$qs.stringify(pd))
        .then(res => {
          this.dataList = res.data.data
        })
        .catch(err => {
          console.error(err)
        })
    },
    /**
     * 我的消费记录
     */
    searchIndex() {
      const pd = {
        keyword: this.searchContent,
        today: '1'
      }
      index(this.$qs.stringify(pd))
        .then(res => {
          this.dataList = res.data.data
        })
        .catch(err => {
          console.error(err)
        })
    },
    /**
     * 钱包余额
     */
    myInfo() {
      const pd = {}
      myInfo(this.$qs.stringify(pd))
        .then(res => {
          if (res.data.code === 1) {
            this.info = res.data.data
          } else {
            this.$message.error(res.data.msg)
          }
        })
    }
  }
}
</script>
<style lang="scss" scoped>
.box {

  /* 标题 */
  .title {
    background-image: linear-gradient(to bottom, #7ac91b 65%, #f5f5f5 0);
    font-weight: bold;

    .title_fan {
      color: #fff;
      font-size: 18px;
      padding: 15px;
      display: flex;
      justify-content: space-between;
      align-items: center;

      img {
        width: 13px;
        height: 13px;
      }
    }

    .title_cen {
      font-weight: normal;
      margin: 0 5%;
      padding: 30px 15px;
      background-color: #fff;
      border-radius: 15px;
      box-shadow: 0 0 10px #ccc;
      text-align: center;
      color: #333333;

      .title_cen_size {
        font-size: 11px;
        margin: 30px 0 15px 0;
      }

      .title_cen_flex {
        display: flex;
        justify-content: center;
        align-items: center;
        font-size: 21.5px;
        font-weight: bold;

        img {
          width: 21px;
          height: 21px;
          margin-right: 6px;
        }
      }
    }
  }

  // 背景卡
  .back_card {
    margin: 7px;

    .back_card_flex {
      display: flex;
      justify-content: space-between;

      > div {
        padding: 5% 0;
        width: 50%;
        text-align: center;
        color: #FFFFFF;
        font-size: 13px;
        background-repeat: no-repeat;
        background-size: 100% 100%;
      }

      .back_card_ten {
        background-image: url(../../../../assets/static/walletDetail/10.png);
      }

      .back_card_eleven {
        background-image: url(../../../../assets/static/walletDetail/11.png);
      }
    }

    .back_card_nine {
      background-image: url(../../../../assets/static/walletDetail/9.png);
      background-repeat: no-repeat;
      background-size: 100% 100%;
      display: flex;
      align-items: center;
      padding: 4% 5% 5% 5%;
      font-size: 12px;
      color: #FFFFFF;

      .back_card_nine_shu {
        width: 1px;
        height: 10px;
        background-color: #fff;
        margin: 0 10px;
      }

      .back_card_nine_juli {
        margin: 0 4px;
      }
    }

    .back_card_color {
      background-color: #fff;
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 5px;
      margin: 8px;
      font-size: 13px;
      box-shadow: 0 5px 10px #CCCCCC;
      border-radius: 8px;

      > div {
        display: flex;
        align-items: center;
      }

      img {
        width: 35px;
      }

      .back_card_color_right {
        color: #999999;

        .el-icon-arrow-right {
          margin-left: 7px;
        }
      }
    }
  }

  .walletDeal {
    margin: 15px;

    .card_title {
      display: flex;
      align-items: center;
      font-size: 15px;
      font-weight: bold;
      background: none;
      box-shadow: none;
      padding: 0;
      margin: 0;

      > div {
        margin-left: 13px;
      }
    }

    .walletDeal_img {
      background-image: url(../../../../assets/static/walletDetail/7.png);
      background-repeat: no-repeat;
      background-size: 100% 100%;
      text-align: center;
      width: 200px;
      height: 178px;
      margin: 60px auto;
      display: flex;
      flex-wrap: wrap;
      align-items: end;

      .walletDeal_img_size {
        width: 100%;
        font-size: 14px;
        font-weight: bold;

        > div:nth-child(2) {
          font-size: 11px;
          color: #999;
          font-weight: normal;
          margin-top: 12px;
        }
      }
    }
  }
}
</style>
<style scoped>
.height_flex_img > img {
  height: 50%;
  width: 50%;
}

/*  */
.consume_input {
  margin: 15px;
}

.consume_input input {
  box-shadow: 0 0 5px #ccc;
  width: 98%;
  text-align: center;
  outline: none;
  border: none;
  height: 40px;
  border-radius: 10px;
}

.consume_input input::-webkit-input-placeholder {
  color: #67C41D;
}

/* 标题卡 */
.title_card {
  background-color: rgba(193, 225, 169, 0.5);
  padding: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: #64BE1D;
  border-radius: 10px;
}

.title_card_back {
  width: 120px;
  overflow: hidden;
  background-color: #fff;
  /*padding: 8px;*/
  border-radius: 8px;
}

.title_card_back .el-icon-arrow-down {
  margin-left: 3px;
}

/*  */
.card_back {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: #fff;
  margin: 10px 0;
  padding: 10px;
  border-radius: 10px;
  color: #63BD1F;
  font-size: 18px;
  font-weight: bold;
}

.card_back img {
  width: 45px;
  margin-right: 10px;
  margin-top: 5px;
}

.card_back > div:nth-child(1) {
  display: flex;
  align-items: center;
  font-size: 11px;
  color: #999999;
  font-weight: normal;
}

.card_back > div:nth-child(1) > div > div:nth-child(1) {
  margin-bottom: 3px;
  font-size: 13px;
  font-weight: bold;
  color: #333333;
}

</style>
<style lang="scss" scoped>
.back_card_font {
  width: 156px;
}

.comsum {
  align-items: flex-start;
}

.userName {
  color: rgba(67, 207, 124, 1);
  font-size: 20px;
  line-height: 150%;
  text-align: left;
  font-weight: bold;
}

.box {

  /* 标题 */
  .title {
    background-image: linear-gradient(to bottom, #7ac91b 65%, #f5f5f5 0);
    font-weight: bold;

    .title_fan {
      color: #fff;
      font-size: 18px;
      padding: 15px;
      display: flex;
      justify-content: space-between;
      align-items: center;

      img {
        width: 13px;
        height: 13px;
      }
    }

    .title_cen {
      font-weight: normal;
      margin: 0 5%;
      padding: 30px 15px;
      background-color: #fff;
      border-radius: 15px;
      box-shadow: 0 0 10px #ccc;
      text-align: center;
      color: #333333;

      .title_cen_size {
        font-size: 11px;
        margin: 30px 0 15px 0;
      }

      .title_cen_flex {
        display: flex;
        justify-content: center;
        align-items: center;
        font-size: 21.5px;
        font-weight: bold;

        img {
          width: 21px;
          height: 21px;
          margin-right: 6px;
        }
      }
    }
  }

  // 背景卡
  .back_card {
    margin: 7px;

    .back_card_flex {
      display: flex;
      justify-content: space-between;

      > div {
        width: 50%;
        padding: 5%;
        color: #FFFFFF;
        background-repeat: no-repeat;
        background-size: 100% 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
        flex-wrap: wrap;
        justify-content: center;

        > div:nth-child(odd) {
          font-size: 10px;
          font-weight: bold;
        }

        > div:nth-child(2) {
          font-size: 14px;
        }
      }

      .back_card_ten {
        background-image: url(../../../../assets/static/payment/8.png);
      }

      .back_card_eleven {
        background-image: url(../../../../assets/static/payment/7.png);
      }
    }

    .card_back_list {
      padding: 14px 8px;
      overflow: auto;
      white-space: nowrap;

      > div {
        display: inline-block;
        width: 70px;
        text-align: center;
        padding: 9px;
        background-color: #fff;
        margin-right: 20px;
        font-size: 11px;
        border-radius: 10px;
        box-shadow: 0 0 10px #ccc;
      }

      > div:active {
        background-image: linear-gradient(to right, #7AC91B, #5FBE00);
        color: #FFFFFF;
        box-shadow: 0 0 10px #5FBE00;
      }

      //.crad_back_list_color {
      //  background-image: linear-gradient(to right, #7AC91B, #5FBE00);
      //  color: #FFFFFF;
      //  box-shadow: 0 0 10px #5FBE00;
      //}
    }

    .card_back_list::-webkit-scrollbar {
      display: none
    }
  }

  .painting_img:nth-child(4) {
    margin-bottom: 100px;
  }

  // 让您画的钱更有价值
  .painting_img {
    margin: 15px;

    .painting_img_title {
      margin: 12px 0;
      display: flex;
      align-items: center;
      font-size: 15px;
      font-weight: 600;

      > div {
        margin-left: 13px;
      }
    }

    .painting_img_list {
      overflow: auto;
      white-space: nowrap;

      > div {
        display: inline-block;
        background-repeat: no-repeat;
        background-size: 100% 100%;
        width: 110px;
        height: 98px;
        white-space: normal;
        vertical-align: top;
        font-size: 12px;
        color: #FFFFFF;
        font-weight: bold;
        padding: 30px 20px;
        text-align: center;
      }

      > div:nth-child(1) {
        background-image: url(../../../../assets/static/payment/12.png);
      }

      > div:nth-child(2) {
        background-image: url(../../../../assets/static/payment/6.png);
        white-space: nowrap;
      }

      > div:nth-child(3) {
        background-image: url(../../../../assets/static/payment/5.png);
      }
    }

    // 清楚滚动条
    .painting_img_list::-webkit-scrollbar {
      display: none
    }
  }


  // 最近交易
  .recentlyDeal {
    overflow: scroll;

    .recentlyDeal_card {
      margin: 10px 0 0 0;
      background-color: #fff;
      border-radius: 10px;
      box-shadow: 0 0 10px #ccc;

      > div {
        padding: 12px;
        border-bottom: #B4B4B4 solid 1px;
      }

      > div:last-child {
        border: none;
      }

      .recentlyDeal_card_input {
        > div {
          display: flex;
          align-items: center;
          justify-content: space-between;
          padding: 10px;
          border: #DCDCDC solid 1.5px;
          border-radius: 10px;

          input {
            width: 90%;
            border: none;
            outline: none;
          }

          img {
            width: 14px;
          }
        }
      }

      .recentlyDeal_card_flex {
        display: flex;
        justify-content: space-between;

        > div:nth-child(1) {
          display: flex;
          align-items: center;

          img {
            width: 47px;
            margin-right: 7px;
          }

          > div {
            color: #999;
            font-size: 10px;

            > div:nth-child(1) {
              margin-bottom: 10px;
              color: #333;
              font-size: 12px;
              font-weight: bold;
            }
          }
        }

        > div:nth-child(2) {
          font-size: 10px;
          color: #999;

          > div:nth-child(1) {
            display: flex;
            justify-content: space-between;
            align-items: center;
            font-size: 13px;
            font-weight: bold;
            margin-bottom: 10px;
            color: #333333;

            img {
              margin-left: 6px;
            }
          }
        }
      }
    }
  }
}
</style>
